<template>
  <div class="edit-form edit-dialog">
    <el-form :model="form" ref="formRef" label-width="140px">
      <el-descriptions
        :column="2"
        border
        :colon="true"
        label-class-name="custom-description-label-160"
      >
        <el-descriptions-item :span="2">
          <template #label>
            <span class="colorRed">*</span>
            经办意见
          </template>
          <el-form-item prop="grantComment" :rules="$formRules.input">
            <el-input
              type="textarea"
              maxlength="200"
              show-word-limit
              v-model="state.editForm.grantComment"
              placeholder="请输入"
            />
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item>
          <template #label>当前机构运营状态</template>
          <el-form-item prop="beforeOperationState" :rules="$formRules.select">
            <pub-dict-select
              width="100%"
              disabled
              v-model="form.beforeOperationState"
              dict-code="JGYYZT"
              placeholder="请选择"
            />
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item>
          <template #label>
            <span class="colorRed">*</span>
            当前进行的操作
          </template>
          <el-form-item prop="afterOperationState" :rules="$formRules.select">
            <pub-dict-select
              width="100%"
              v-model="form.afterOperationState"
              dict-code="JGYYZT"
              placeholder="请选择"
            />
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item :span="2">
          <template #label>
            <span class="colorRed">*</span>
            原因描述
          </template>
          <el-form-item prop="reason" :rules="$formRules.input">
            <el-input
              type="textarea"
              v-model="form.reason"
              show-word-limit
              maxlength="200"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item>
          <template #label>
            <span class="colorRed">*</span>
            经办人
          </template>
          <el-form-item prop="handler" :rules="$formRules.input">
            <el-input
              type="text"
              v-model="form.handler"
              placeholder="请输入"
              maxlength="50"
            ></el-input>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item>
          <template #label>
            <span class="colorRed">*</span>
            备注
          </template>
          <el-form-item prop="operateDate" :rules="$formRules.select">
            <el-input
              type="textarea"
              maxlength="200"
              show-word-limit
              v-model="state.editForm.remarks"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item :span="2">
          <template #label>附件材料</template>
          <div class="colorRed upload-hint">
            支持文件格式：jpg、jpeg、png、doc、docx、pdf；单个文件大小不能超过8M；最多上传10个文件
          </div>
          <el-form-item>
            <pub-upload
              :allowUploadTypes="['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf']"
              v-model:bizId="form.material"
              limit="10"
              :file-size="8"
            />
          </el-form-item>
        </el-descriptions-item>
      </el-descriptions>
    </el-form>
    <div class="btn-group">
      <el-button type="default" size="small" @click="emit('cancel')">
        取消
      </el-button>
      <el-button
        type="primary"
        :loading="btnLoading"
        v-prevent-repeat-click
        @click="submitForm()"
      >
        保存
      </el-button>
    </div>
  </div>
</template>
<script setup>
import { defineProps, onMounted, onBeforeMount, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { useUserStore } from '@/pinia/modules/user'
import { changeOrgOperateStatus } from '@/api/ZFJG/FWJGGL/JGXXGL'
const emit = defineEmits(['cancel', 'success'])
const btnLoading = ref(false)

const props = defineProps({
  orgData: {
    type: Object
  }
})

const formRef = ref(null)
const orgInfo = useUserStore().orgInfo
const form = ref({
  pensionOrganizationId: ''
})
const submitForm = status => {
  formRef.value.validate(async valid => {
    if (valid) {
      btnLoading.value = true
      let res = await changeOrgOperateStatus(form.value)
      if (res.succeed) {
        ElMessage.success(res.msg)
        emit('success')
      }
      emit('cancel')
      btnLoading.value = false
    }
  })
}

onBeforeMount(() => {
  console.log(props.orgData)
  form.value = props.orgData
})

onMounted(() => {})
</script>
<style lang="scss" scoped>
.btn-group {
  text-align: center;
}
</style>
